package 算法.搜索算法;

/**
 * @author Zhu
 * @Description
 * @create 2023-03-09
 */
public class JZ4二维数组中的查找 {
    public boolean Find(int target, int [][] array) {
        int row = array.length-1;
        int col = array[0].length-1;
        if(row == 0 || col==0)
                return  false;
        for(int i=row,j=0;i>=0&&j<=col;){
            if(array[i][j] > target)
                i--;
            else if(array[i][j] < target)
                j++;
            else
                return  true;
        }
        return  false;
    }
}
